import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../components/Home.vue'
import User from '../components/User.vue'
import Student from '../components/Student.vue'
import Login from '../components/Login.vue'
import Welcome from '../components/Welcome.vue'
import NaturalCalculate from '../components/calculate/NaturalCalculate.vue'
import ForceCalculate from '../components/calculate/ForceCalculate.vue'
import OpenProject from '../components/calculate/OpenProject.vue'
import PorjectInfo from '../components/infoProject/ProjectInfo.vue'
import LanguageChange from '../components/options/LanguageChange.vue'
import UnitChange from '../components/options/UnitChange.vue'
import CreateProject from '../components/project/CreateProject.vue'
import RetrieveProject from '../components/project/RetrieveProject.vue'
import SaveProject from '../components/project/SavaProject.vue'
import UpdateCase from '../components/updateData/UpdateCase.vue'
import UpdateHeat from '../components/updateData/UpdateHeat.vue'
import UserInfo from '../components/user/UserInfo.vue'
Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/login' },
  { path:'/login',component:Login},
  { path:'/home',component:Home,redirect:'/welcome',
    children:[
      {path:'/welcome',component:Welcome},
      {path:'/naturalCalculate',component:NaturalCalculate},
      {path:'/forceCalculate',component:ForceCalculate},
      {path:'/openProject',component:OpenProject},
      {path:'/projectInfo',component:PorjectInfo},
      {path:'/languageChange',component:LanguageChange},
      {path:'/unitChange',component:UnitChange},
      {path:'/createProject',component:CreateProject},
      {path:'/retrieveProject',component:RetrieveProject},
      {path:'/saveProject',component:SaveProject},
      {path:'/updateCase',component:UpdateCase},
      {path:'/updateHeat',component:UpdateHeat},
      {path:'/userInfomation',component:UserInfo}
    ]},

]

const router = new VueRouter({
  routes
})
// 添加导航守卫
// router.beforeEach((to,from,next) =>{
//     if(to.path ==='/login') return next()
//     //如果用户访问的网址不是/login 获取token
//     let token =window.sessionStorage.getItem("token")
//     if(token) return next()
//     //如果程序执行到这一行 说明token没有数据 跳转到登录页面
//      next('/login')
// })
export default router
